import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:flutter_base_widget/main.dart';

class TestPeople {
  int type;
  String name;

  TestPeople(this.type, this.name);
}

void main() {
  testWidgets('Counter increments smoke test', (WidgetTester tester) async {
    //定义集合
    List<TestPeople> testList = [
      TestPeople(1, "张三"),
      TestPeople(2, "李四"),
      TestPeople(1, "王五")
    ];

    for (var element in testList) {
      debugPrint("${element.name} ");
    }

    //转换类型
    var newList = testList
        .where(
          (people) => people.type == 1,//条件判断筛选
        )
        .map(
          (people) => people.name,//构建新的集合使用的数据
        )
        .toList();

    ///输出一下   newList 的类型
    /// List<String>
    debugPrint("${newList.runtimeType}");

    for (String item in newList) {
      debugPrint("newList-> $item");
    }

  });
}
